package model;

public class Act_Fou_Manger extends Act_Fourmi{

	public Act_Fou_Manger(Ind_Fourmi _fourmiHote) {		
		super(_fourmiHote);		
	}

	protected void updatePriority(){
		priority = 24 - fourmiHote.getHungryCount()/60;
	}

	@Override
	protected void doAction() {
		if(fourmiHote.atHome()){	
			if(canEat()){				
				eat();
				updatePriority();
			}			
		}
	}
	

	private boolean canEat(){
		if(fourmiHote.getPoid() < getFourmiliere().getFoodStock()) return true;
		return false;
	}
	
	private void eat(){
		if(getFourmiliere().eatFood(fourmiHote.getPoid()) == fourmiHote.getPoid()){
			fourmiHote.setHungryCounter(MonTimer.u_jour);
		}
	}
	
}
